package com.cks.eduservice.controller;


import com.cks.commonutils.R;
import com.cks.eduservice.entity.subject.OneSubject;
import com.cks.eduservice.service.EduSubjectService;
import com.cks.eduservice.service.impl.EduSubjectServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2022-01-16
 */
@RestController
@RequestMapping("/eduservice/edu-subject")
@CrossOrigin
public class EduSubjectController {

  @Autowired
  private EduSubjectService SubjectService;

  //添加课程分类
    //获取上传过来文件，把文件内容读取出来
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){
        SubjectService.saveSubject(file,SubjectService);
        return R.ok();
    }

    //课程分类列表（树型）
    @GetMapping("getAllSubject")
    public  R getAllSubject()
    {
       List<OneSubject> list= SubjectService.getAllOneTwoSubject();
    //    SubjectService.getAllSubject();
        return R.ok().data("list", list);
    }
}

